﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace INSAForManagers
{
    public partial class FormUserList : Form
    {
        private FormACard parent;
        private ArrayList list;

        public FormUserList(FormACard p, ArrayList list)
        {
            InitializeComponent();
            this.parent = p;
            this.list = list;
            this.Location = new Point(p.Location.X + 200, p.Location.Y + 50);
            
        }

        private void FormUserList_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < list.Count; i++)
            {
                ArrayList tmp = (ArrayList)list[i];
                lstUser.Items.Add(tmp[0].ToString() + "(" + tmp[1].ToString() + "," + tmp[2].ToString() +  ")");
            }
        }

        private void lstUser_DoubleClick(object sender, EventArgs e)
        {
            if (lstUser.SelectedIndex > -1)
            {
                string item = lstUser.SelectedItem.ToString();
                parent.txtPCode.Text = item.Substring(0, 10);
                parent.txtName.Text = DBUtil.getMTargetName(parent.txtPCode.Text);
                parent.txtLicenseSubject.Text = DBUtil.getSubjectInfo(parent.txtPCode.Text);
                parent.txtOrganName.Text = DBUtil.getOrganName(Config.Mvi.Organ);
            }

            this.Close();
        }
    }
}
